package com.example.feigntest.controller;

import com.example.feigntest.customconfig.requestinterceptor.CustomFeignRequestInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 描述：
 *
 * @author YangQun by 2020/10/17
 */
@RestController
public class FeignRequestInterceptorTestController {

    private final Logger log = LoggerFactory.getLogger(getClass());

    /**
     * 换行符
     */
    private static final String LINE_SEPARATOR = System.lineSeparator();

    public static final String URI = "interceptorTest";


    @PostMapping(URI)
    public void test(@RequestBody Map<String, Object> m, HttpServletRequest servletRequest){

        String customHeaderValue = servletRequest.getHeader(CustomFeignRequestInterceptor.CUSTOM_HEADER);

        log.info("{}FeignRequestInterceptorTestController 接收到头信息{}={}",
                LINE_SEPARATOR, CustomFeignRequestInterceptor.CUSTOM_HEADER, customHeaderValue);

        log.info("{}FeignRequestInterceptorTestController 接收到信息 : {}", LINE_SEPARATOR, m);
    }

}
